Dearest Reviewer,
This pull request allows the value of project.links to be passed into
the build script via an environment variable. This closes #1220 . I have
added a test that makes sure that the environment variable is set. Also
note I am using CARGO_LIB not LIB because it appears to be used for
windows in appveyor. I think CARGO_LIB fits better.
I have also updated the documentation to reflect the new variable.
Thanks!
Becker
[Updated]
Github comments moved to CARGO_MANIFEST_LINKS
Fix if statement
.env("PROFILE", if cx.build_config.release {"release"} else {"debug"})
.env("HOST", &cx.config.rustc_info().host);
+ if let Some(links) = unit.pkg.manifest().links(){
+ p.env("CARGO_MANIFEST_LINKS", links);
+ }
+
// Be sure to pass along all enabled features for this package, this is the
// last piece of statically known information that we have.
if let Some(features) = cx.resolve.features(unit.pkg.package_id()) {
script). Also note that this is the value of the
current working directory of the build script when it
starts.
+* `CARGO_MANIFEST_LINKS` - the manifest `links` value.
* `CARGO_FEATURE_<name>` - For each activated feature of the package being
built, this environment variable will be present
where `<name>` is the name of the feature uppercased
"#)
.file("a/src/lib.rs", "")
.file("a/build.rs", r#"
+ use std::env;
fn main() {
+ let lib = env::var("CARGO_MANIFEST_LINKS").unwrap();
+ assert_eq!(lib, "foo");
+
println!("cargo:foo=bar");
println!("cargo:bar=baz");
}